import type * as Store from './type'
import http from '@/utils/http'

const BASE_URL = '/store/shipping'

export interface ShippingTemplatesPageQuery extends Store.ShippingTemplatesQuery, PageQuery {}

/** @desc 查询运费模板列表 */
export function listShippingTemplates(query: ShippingTemplatesPageQuery) {
  return http.get<PageRes<Store.ShippingTemplatesResp[]>>(`${BASE_URL}`, query)
}

/** @desc 查询运费模板详情 */
export function getShippingTemplates(id: string) {
  return http.get<Store.ShippingTemplatesDetailResp>(`${BASE_URL}/${id}/info`)
}

/** @desc 新增运费模板 */
export function addShippingTemplates(data: any) {
  return http.post(`${BASE_URL}/create`, data)
}

/** @desc 获取所有运费模板 */
export function getAllShippingTemplates() {
  return http.get(`${BASE_URL}/all`)
}

/** @desc 修改运费模板 */
export function updateShippingTemplates(data: any, id: string) {
  return http.patch(`${BASE_URL}/${id}/update`, data)
}

/** @desc 删除运费模板 */
export function deleteShippingTemplates(id: string) {
  return http.patch(`${BASE_URL}/${id}/remove`)
}

/** @desc 导出运费模板 */
export function exportShippingTemplates(query: Store.ShippingTemplatesQuery) {
  return http.download<any>(`${BASE_URL}/export`, query)
}
